package oop.ex2.tokenizer;

import oop.ex2.expression.ExpressionNode;
import oop.ex2.expression.SequenceExpressionNode;

/**
 * This searches for the beginning on a parenthesis section. It returns an expression
 * Node that creates a sequence expression until it encounters a closing parenthesis.
 * 
 * This lets the tokenizer parse the parenthesis in a recursive fashion.
 * @author daniel_i_l
 *
 */
public class OpenParenthesisAnalyzer extends TokenAnalyzer {
	private static final String PATTERN = "\\[" ;
	private static final String PARENTHESIS_CLOSE = "]";
	
	/**
	 * Initialize the pattern.
	 */
	public OpenParenthesisAnalyzer() {
		super(PATTERN);
	}

	@Override
	public ExpressionNode getExpressionNode() {
		SequenceExpressionNode output = new SequenceExpressionNode(_matchedString, true);
		output.addTerminatingString(PARENTHESIS_CLOSE);
		return output;
	}

}
